package com.jadefashion.web;

public class Mytest01 {
    public static void main(String[] args) {
        final Count count = new Count();
        for (int i = 0; i < 1000; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    count.addCount();
                }
            }).start();
        }

        System.out.println(count.getCount());
    }
}

class Count{
    private volatile int count;
    public synchronized void addCount(){
         count++;
    }
    public int getCount(){
        return count;
    }
}
